package com.itheima.tanhua.controller;/*limyonna
 2022/4/8 9:50*/


import com.itheima.tanhua.service.PeachblossomService;
import com.itheima.tanhua.vo.AcousticVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("/peachblossom")
public class PeachblossomController {


    @Autowired
    private PeachblossomService peachblossomService;

    /**
     * 桃花传音 发送语音
     *
     * @param soundFile 文件名
     * @return
     */
    @PostMapping
    public ResponseEntity sendVoice(MultipartFile soundFile) throws IOException {
        peachblossomService.sendVoice(soundFile);
        return ResponseEntity.ok(null);
    }

    /**
     * 桃花传音 接收语音
     *
     * @return
     */
    @GetMapping
    public ResponseEntity getVoice() {
        AcousticVo result = peachblossomService.getPeachblossomOne();
        return ResponseEntity.ok(result);
    }

}
